package com.diqizu.dao;

import java.sql.ResultSet;

import java.sql.SQLException;
import java.util.ArrayList;

import com.diqizu.entity.GongSi;

import com.diqizu.utli.DBManager;
import com.diqizu.utli.QueryDataResult;

/**
 * ˾ҳ
 * 
 * @author
 *
 */
public class GonSiDaoImpl {
	public GongSi getALlgs() {
		String sql = " select * from gsinfo";
		System.out.println("查询的语句是:" + sql);
		QueryDataResult execQuery = DBManager.execQuery(sql);
		if (execQuery != null) {
			ResultSet rs = execQuery.rs;
			try {
				if (rs.next()) {
					GongSi e = new GongSi();
					e.setId(rs.getInt(1));
					e.setHomeIntro(rs.getString(2));
					e.setInfo(rs.getString(3));
					e.setZsTel(rs.getInt(4));
					e.setTel(rs.getInt(5));
					e.setAdress(rs.getString(6));
					e.setX(rs.getString(7));
					e.setY(rs.getString(8));
					System.out.println("查询的是" + e);
					return e;
				}
			} catch (SQLException e) {
				e.printStackTrace();
			} finally {
				execQuery.close();
			}
		}
		return null;
	}

	public ArrayList<GongSi> getALllb2() {
		String sql = "select * from gsinfo";
		System.out.println("ִ查询的语句是:" + sql);
		QueryDataResult execQuery = DBManager.execQuery(sql);
		ArrayList<GongSi> list = new ArrayList<GongSi>();
		if (execQuery != null) {
			ResultSet rs = execQuery.rs;
			try {
				if (rs.next()) {
					GongSi e = new GongSi();
					e.setId(rs.getInt(1));
					e.setHomeIntro(rs.getString(2));
					e.setInfo(rs.getString(3));
					e.setZsTel(rs.getInt(4));
					e.setTel(rs.getInt(5));
					e.setAdress(rs.getString(6));
					e.setX(rs.getString(7));
					e.setY(rs.getString(8));
					list.add(e);

				}
			} catch (SQLException e) {
				e.printStackTrace();
			} finally {
				execQuery.close();
			}
		}
		System.out.println(list);
		return list;
	}

	public boolean getALllb7(GongSi GonSi) {
		String sql = "update gsinfo set homeIntro='" + GonSi.getHomeIntro() + "',info='" + GonSi.getInfo() + "',zsTel='"
				+ GonSi.getZsTel() + "',tel='" + GonSi.getTel() + "',adress='" + GonSi.getAdress() + "',x='"
				+ GonSi.getX() + "',y='" + GonSi.getY() + "'where id=" + GonSi.getId();
		System.out.println("ִ查询的语句是:" + sql);
		return DBManager.execUpdate(sql);

	}
}